﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace BSU.GraduateWork.Utilities
{
    public interface IConfiguration
    {
        string DBConnectionString { get; }
    }

    public class Configuration : IConfiguration
    {
        #region Const

        private const string ConnectionStringParamName = "GraduateWorkConnectionString";

        #endregion

        #region IConfiguration Members

        public string DBConnectionString
        {
            get
            {
                ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringParamName];
                if (connectionString == null)
                {
                    throw new ApplicationException("GraduateWork DB connection string is not defined in config file.");
                }
                return connectionString.ConnectionString;
            }
        }

        #endregion
    }
}
